from ctypes import *

'''
python和c的结构体映射
'''


class OrderField(Structure):
    _fields_ = [("orderRef", c_int),
                ("sessionId", c_int),
                ("batchNo", c_int),
                ("orderId", c_int),
                ("exchangeOrderId", c_char * 32),
                ("exchangeId", c_char),
                ("securityId", c_char * 20),
                ("securityName", c_char * 33),
                ("direction", c_char * 2),
                ("limitPrice", c_double),
                ("totalOriginalVolume", c_double),
                ("orderStatus", c_short),
                ("avgPrice", c_double),
                ("tradedVolume", c_double),
                ("tradeAmount", c_double),
                ("frozenAmount", c_double),
                ("frozenVolume", c_double),
                ("orderDate", c_char * 9),
                ("orderTime", c_char * 9),
                ("orderSubmitTime", c_char * 9),
                ("cancelVolume", c_double),
                ("cancelTime", c_char * 9),
                ("cancelSubmitTime", c_char * 9),
                ("fee", c_double),
                ("orderType", c_char),
                ("holderNo", c_char * 17),
                ("cancelFlag", c_int),
                ("cancelFlag2", c_int),
                ("cancelOrderId", c_int),
                ("orderChangeType", c_int),
                ("algoType", c_char * 3),
                ("additionFee", c_double),
                ("entrustType", c_char * 5),
                ("entrustSubBusi", c_char * 4),
                ("promiseNo", c_char * 13),
                ("stockAttribute", c_char * 4),
                ("orderSubmitMilliSecTime", c_int),
                ("rDate", c_char * 9)]


class OrderType(Structure):
    _fields_ = [("exchangeId", c_char),
                ("orderRef", c_int),
                ("securityId", c_char * 20),
                ("direction", c_char * 2),
                ("limitPrice", c_double),
                ("totalOriginalVolume", c_double),
                ("orderType", c_char),
                ("holderAccNo", c_char * 17),
                ("subBusinessType", c_char * 4),
                ("sourceTerminalInfo", c_char * 300),
                ("instructid", c_int),
                ("OrderProp", c_int)]


class ReqSingleOrderInsertField(Structure):
    _fields_ = [("order", OrderType),
                ("batchId", c_int),
                ("branchCode", c_char * 4),
                ("entrustType", c_char * 5),
                ("bankCode", c_char * 7),
                ("bankAccNo", c_char * 41),
                ("orderRiskTestFlag", c_char_p),
                ("BShareClearNum", c_char * 9),
                ("lowPriceOrderConfFlag", c_char * 2),
                ("custOrderConfFlag", c_char * 2),
                ("specSerialNo", c_char * 13),
                ("stockAttribute", c_char * 4),
                ("promiseNo", c_char * 13),
                ("oppositeTradeUnit", c_char * 13),
                ("peerHolderAccNo", c_char * 17),
                ("seatNo", c_char * 9)]


class ReqUserLoginField(Structure):
    _fields_ = [("cust_type", c_char),
                ("cert_no", c_char * 51),
                ("password", c_char * 33),
                ("sourceTerminalInfo", c_char * 300)]
